<#include "/macro_.ftl">
package ${packageCode}.${moduleMapperCode}.service;

import ${packageCode}.${moduleMapperCode}.dto.${businessCode}Dto;
import ${packageCode}.${moduleMapperCode}.entity.${businessCode};
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import top.cardone.context.annotation.Event;
import top.cardone.context.annotation.Events;
import top.cardone.context.event.SimpleErrorEvent;
import top.cardone.context.event.SimpleEvent;
import top.cardone.data.mybatisplus.service.MybatisPlusService;

import java.io.Serializable;
import java.util.Map;

/**
 * ${moduleName}-${businessName}服务
 *
 * @author yao hai tao
 */
@CacheConfig(cacheNames = {"${packageCode}.${moduleMapperCode}.service.${businessCode}Service"})
@Events({@Event(applicationEvent = SimpleErrorEvent.class),
        @Event(applicationEvent = SimpleEvent.class)})
public interface ${businessCode}Service extends MybatisPlusService<${businessCode}> {
    /**
     * 更新一条记录，及关联表记录
     *
     * @param updateParam
     * @return
     */
    @Transactional
    @CacheEvict(allEntries = true)
    boolean updateById(${businessCode}Dto updateParam);

    /**
     * 更新一条记录，及关联表记录
     *
     * @param updateParam
     * @return
     */
    @Transactional
    @CacheEvict(allEntries = true)
    default boolean updateByIdCache(${businessCode}Dto updateParam) {
        return this.updateById(updateParam);
    }

    /**
     * 插入一条记录，及关联表记录
     *
     * @param saveParam
     * @return
     */
    @Transactional
    @CacheEvict(allEntries = true)
    boolean save(${businessCode}Dto saveParam);

    /**
     * 插入一条记录，及关联表记录
     *
     * @param saveParam
     * @return
     */
    @Transactional
    @CacheEvict(allEntries = true)
    default boolean saveCache(${businessCode}Dto saveParam) {
        return this.save(saveParam);
    }

    /**
     * 根据 ${(businessCode?uncap_first)!''}Code 查询
     *
     * @param ${(businessCode?uncap_first)!''}Code
     * @return
     */
    ${businessCode} getBy${businessCode}Code(Serializable ${(businessCode?uncap_first)!''}Code);

    /**
     * 根据 ${(businessCode?uncap_first)!''}Code 查询
     *
     * @param ${(businessCode?uncap_first)!''}Code
     * @return
     */
    @Cacheable
    default ${businessCode} getBy${businessCode}CodeCache(Serializable ${(businessCode?uncap_first)!''}Code) {
        return this.getBy${businessCode}Code(${(businessCode?uncap_first)!''}Code);
    }

    /**
     * 翻页查询
     *
     * @param param 翻页对象
     */
    Page<${businessCode}Dto> pageByParam(Map<String, Object> param);
}